package com.example.note;

import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.note.util.BeatAble;
import com.example.note.util.HeartBeatGenerator;


public class SplashActivity extends Activity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        RelativeLayout relativeLayout = findViewById(R.id.container);
        TextView textView = findViewById(R.id.text_2);
        TextView textView1 = findViewById(R.id.text_1);

        ValueAnimator colorAnim = ObjectAnimator.ofInt(relativeLayout,"backgroundColor", getResources().getColor(R.color.colorPrimaryDarkMore), getResources().getColor(R.color.colorPrimary));
        colorAnim.setDuration(1000);
        colorAnim.setEvaluator(new ArgbEvaluator());
        colorAnim.start();

        ValueAnimator text02 = ObjectAnimator.ofFloat(textView1,"alpha", 0.5f, 1.0f);
        text02.setDuration(450);
        text02.start();

        ValueAnimator text01 = ObjectAnimator.ofFloat(textView,"alpha", 0.3f, 1.0f);
        text01.setDuration(800);
        text01.start();

        HeartBeatGenerator heartBeatGenerator = new HeartBeatGenerator(new BeatAble() {
            @Override
            public void beat() {
                SplashActivity.this.startActivity(new Intent(SplashActivity.this,MainActivity.class));
                finish();
            }

            @Override
            public boolean isStillBeat() {
                return false;
            }
        },1300,1300);

        heartBeatGenerator.startBeat();
    }
}
